using UnityEngine;
using System.Collections;

public class NewLogo : MonoBehaviour {

    public GameObject logo; 
    public Transform blank;
    private float distance;

    private bool ready;

    IEnumerator Start()
    {
        Color randomColor = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), 1);

        if (randomColor.Equals(Color.black))
        {
            randomColor = new Color(Random.Range(0.0f, 0.5f), Random.Range(0.0f, 0.5f), Random.Range(0.0f, 0.5f), 1);
        }

        renderer.material.color = randomColor;

        distance = 38.26f - 20.2f;
        yield return new WaitForSeconds(3f);
        gameObject.AddComponent("IntroAnimation");
        yield return new WaitForSeconds(3);
        ready = true;
    }

	void Update () 
    {
        if (ready)
        {
            transform.Translate(0.4f, 0, 0);
            if (transform.position.x > -38.26f && transform.position.x < -20.2)
            {
                blank.localScale = new Vector3(Mathf.Abs(-38.26f - transform.position.x) / distance + 0.1f, blank.localScale.y, blank.localScale.z);

            }
            if (transform.position.x > -20)
            {
                gameObject.SetActive(false);
                logo.SetActive(true);
            }
        }
	}
}